<?
$tbl_content = "xteam_product";
$Item_type = getRecord("xteam_product", "id=".$id);
if($Item_type){
$properties = product_properties($id);
$ali = $_GET['ali'];
//$urlshare = $curHost.'1/'.$cat.'/'.$ali.'.html';
$viewed = $Item_type['views']+1;
$updateviews = array('views'=>$viewed);
update('xteam_product', $updateviews, 'id='.$Item_type['id']);
?>
<div class="description">
    <p style="height: 40px;">
        Ngày đăng: <?=date('d-m-Y',$Item_type['date_added'])?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        Lượt xem: <?=$Item_type['views']?>
    </p>
    <div class="img" style="position:relative;">
        <? if($Item_type["image_large"]){?>
        <a href="<?=$curHost.$Item_type['image_large']?>" class="lightbox-2" rel="product">
            <img alt="<?=$Item_type["seo_key"]." - ".$Item_type["name"]?>" src="<?=$curHost?><?=$Item_type["image_large"]?>" class="imgsp" />
        </a>
        <?}else{?>
        <img alt="<?=$Item_type["seo_key"]." - ".$Item_type["name"]?>" src="<?=$curHost?>images/no_image.gif" class="imgsp" />
        <? }?>
    </div>
    <div style="height: 25px; line-height: 25px; color: #50ABD1; font-weight: bold;">Thông tin chung</div>
    <ul>
	<?
	if($properties){
    	foreach($properties as $prop){?>
        <li><label><?=$prop['cat']?>:</label><span><?=$prop['name']?></span></li>
	<?
    	}
	}else{?>
        <li><label>đang cập nhật</label></li>
    <? }?>
    </ul>
    <p class="label-price">Giá tham khảo: <br /><?=$Item_type['price']>0?'<font color="#F2B600">'.number_format($Item_type['price'],0,',','.').' '.$currencyUnit.'</font>':'<font color="orange">Thỏa thuận</font>'?></p>
    
    <!-- AddThis Button BEGIN -->
    <div class="addthis_toolbox addthis_default_style " style="float:right;margin: 15px 15px 0 0;">
    <a class="addthis_button_facebook_like" fb:like:layout="button_count"></a>
    <a class="addthis_button_tweet"></a>
    <a class="addthis_counter addthis_pill_style"></a>
    </div>
    <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-50114aa51f6787fb"></script>
    <!-- AddThis Button END -->
    <div class="clear"></div>
</div>
<div class="content-detail">
    <p class="detail-title"><strong>Thông tin chi tiết:</strong></p>
    <?=html_entity_decode($Item_type["detail"], ENT_QUOTES, 'UTF-8');?>
    
    <? if($Item_type["tags"]!==''){?>
    <p><b>Tags:</b>&nbsp;
    <?
        $StrTags = substr($Item_type["tags"],1,-1);
		$ArrTags = explode(',', $StrTags);
        foreach ($ArrTags as $ArrTag){?>
        <a href="<?=$curHost?>tags/<?=str_replace(array('--','--'), '-', utf8_to_ascii(trim($ArrTag)))?>"><?=$ArrTag?></a>,&nbsp;
        <? }?>
    </p>
    <? }?>
    
    <div class="clear"></div>
</div>
<div class="art-blockheader">
    <h3 class="detail-title">Có thể bạn quan tâm</h3>
</div>
<div class="from-gallery-imgs">
    <div class="block-news">
    <?
    //xác định danh mục cha
    $parname = array();
    $parid = array();
    $parseokey= array();
    if($cat_pro){
        foreach ($cat_pro as $parent){
            $parname[$parent['id']] = $parent['name'];
            $parid[$parent['id']] = $parent['id'];
            $parseokey[$parent['id']] = utf8_to_ascii($parent['seo_key']);
        }
    }
    $Item_type_type = getArray('xteam_product','status=1 AND id<>'.$Item_type['id'].' AND parent_id='.$Item_type['parent_id'],NULL,'is_hot DESC,date_added DESC, sort ASC');
	if($Item_type_type){
            foreach ($Item_type_type as $Item_type){
                $num++;
                $class = $num%2!==0? 'block-left' : 'block-right';
                if($parid[$Item_type['parent_id']]%2==0){$class_sp="rental";}else{$class_sp="salse";}?>
                <div class="<?=$class?>">
                    <h3 class="title-news">
                        <?=$Item_type['is_hot']==1?'<img src="'.$curHost.'images/hot.gif" alt="'.utf8_to_ascii($Item_type['name']).'" />':''?>
                        <a href="<?=$curHost.utf8_to_ascii($parseokey[$Item_type['parent_id']]!=''?$parseokey[$Item_type['parent_id']]:$parname[$Item_type['parent_id']]).'/'.utf8_to_ascii($parseokey[$Item_type['parent_id']]!=''?$parseokey[$Item_type['parent_id']]:$parname[$Item_type['parent_id']])?>/7/<?=$parid[$Item_type['parent_id']]?>.html">
                            <span class="<?=$class_sp?>"><?=$parname[$Item_type['parent_id']]?> | </span>
                        </a>
                        <a href="<?=$curHost.utf8_to_ascii($parseokey[$Item_type['parent_id']]!=''?$parseokey[$Item_type['parent_id']]:$parname[$Item_type['parent_id']])?>/<?=utf8_to_ascii($Item_type['seo_key']!=''?$Item_type['seo_key']:$Item_type['name'])?>/1/<?=$Item_type['id']?>.html" title="<?=$Item_type['name']?>">
                            <?=$Item_type['name']?>
                        </a>
                    </h3>
                    <? if($Item_type['image_thumbs']!=''){?>
                    <a href="<?=$curHost.utf8_to_ascii($parseokey[$Item_type['parent_id']]!=''?$parseokey[$Item_type['parent_id']]:$parname[$Item_type['parent_id']])?>/<?=utf8_to_ascii($Item_type['seo_key']!=''?$Item_type['seo_key']:$Item_type['name'])?>/1/<?=$Item_type['id']?>.html" title="<?=$Item_type['name']?>">
                        <img src="<?=$curHost.$Item_type['image_thumbs']?>" alt="<?=$Item_type['seo_key'].'-'.$Item_type['name']?>" class="img-news" title="<?=$Item_type['name']?>" />
                    </a>
                    <? }else{?>
                    <a href="<?=$curHost.utf8_to_ascii($parseokey[$Item_type['parent_id']]!=''?$parseokey[$Item_type['parent_id']]:$parname[$Item_type['parent_id']])?>/<?=utf8_to_ascii($Item_type['seo_key']!=''?$Item_type['seo_key']:$Item_type['name'])?>/1/<?=$Item_type['id']?>.html" title="<?=$Item_type['name']?>">
                        <img src="<?=$curHost?>images/no_image.gif" alt="<?=$Item_type['seo_key']." - ".$Item_type["name"]?>"  class="img-news" style="display: inline;" title="<?=$Item_type['name']?>" />
                    </a>
                    <? }?>
                    <div class="short-news">
                        <ul>
                        <?
                        if($properties){
                            foreach($properties as $prop){?>
                            <li><label><?=$prop['cat']?>:</label><span><?=$prop['name']?></span></li>
                        <?
                            }
                        }else{?>
                            <li><label>đang cập nhật</label></li>
                        <? }?>
                        </ul>
                    </div>
                </div>
                <?

                if($num%2==0 || $num >=count($Item_type_type)){
                    echo '<div class="clear"></div></div><div class="block-news">';
                }
            }
        }?>
    </div>
</div>
<script language="javascript" type="text/javascript">
    $(document).ready(function(){
        var contentdiv = $('.block-news').text(function(){
            if ($.trim($(this).text())==''){
                $(this).hide();
            }
        });
    })
</script>
<?}else{
require_once 'modules/error.php';
}?>